package com.zhouyu.fileSync.FScommon.entities;

import java.util.Objects;

/**
 * Created by zhouyu74748585@hotmail.com on 2019/9/5
 * the transmission route of the file
 **/
public class FileRoute {
    /**
     * the file path of the source file
     */
    private String sourceFilePath;
    /**
     * the target file path where the source file will go
     */
    private String targetFilePath;
    /**
     * if true,will keep sync the file
     */
    private boolean sync;
    /**
     * B：keep the file with bigger size
     * S: keep the file with smaller size
     * O: keep the file with older last modified date;
     * N: keep the file with newer last modified date;
     * [BS][ON]:means compare size first,then compare modified date
     * [ON][BS]:means compare modified date first,then compare size
     */
    private String updateRule;

    public FileRoute() {
    }

    public FileRoute(String sourceFilePath, String targetFilePath, boolean sync, String updateRule) {
        this.sourceFilePath = sourceFilePath;
        this.targetFilePath = targetFilePath;
        this.sync = sync;
        this.updateRule = updateRule;
    }

    public String getSourceFilePath() {
        return sourceFilePath;
    }

    public void setSourceFilePath(String sourceFilePath) {
        this.sourceFilePath = sourceFilePath;
    }

    public String getTargetFilePath() {
        return targetFilePath;
    }

    public void setTargetFilePath(String targetFilePath) {
        this.targetFilePath = targetFilePath;
    }

    public boolean isSync() {
        return sync;
    }

    public void setSync(boolean sync) {
        this.sync = sync;
    }

    public String getUpdateRule() {
        return updateRule;
    }

    public void setUpdateRule(String updateRule) {
        this.updateRule = updateRule;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof FileRoute)) return false;
        FileRoute fileRoute = (FileRoute) o;
        return isSync() == fileRoute.isSync() &&
                getSourceFilePath().equals(fileRoute.getSourceFilePath()) &&
                getTargetFilePath().equals(fileRoute.getTargetFilePath()) &&
                getUpdateRule().equals(fileRoute.getUpdateRule());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getSourceFilePath(), getTargetFilePath(), isSync(), getUpdateRule());
    }
}
